TB_top ?= tb_calc_phase

ifneq (,$(findstring microsoft,$(shell uname -r | tr '[:upper:]' '[:lower:]')))
    PPF = powershell.exe
else
    PPF =
endif


SIM_OPTIONS   := -o sim/build/vvp.exec \
				 -D"timescale 10ns/1ns" \
				 -I "sim/" \
				 -g2005-sv \
				 -f flist.f \
				 -s $(TB_top)

MSIM_OPTION := -c \
			   -voptargs="+acc" -quiet -nostdout \
			   -l sim/build/$(TB_top).log \
			   $(TB_top) \
			   -do \"run -all\; quit -f\"

# iverilog sim
# flist需要末尾有空行，否则报错
isim:
	-rm -r sim/build
	-mkdir -p sim/build
	iverilog ${SIM_OPTIONS}
	vvp sim/build/vvp.exec

iwave:
	@$(PPF) gtkwave sim/build/$(TB_top).vcd


# modelsim sim
msim:
	@-rm -rf sim/build work
	@-mkdir -p sim/build
	@${PPF} vlib work
	@${PPF} vlog -timescale "10ns/1ns" -sv -f flist.f -quiet
	@${PPF} vsim $(MSIM_OPTION)

clean:
	-rm -rf sim/build work transcript 
